package controller;

import java.util.List;

import javax.servlet.http.HttpServletRequest;

import bean.Fund;
import bean.Model;
import bean.UserType;
import dao.FundDAO;

/*
 * 
 * Created By Sahil Thakkar for Sell Fund  Usecase
 */

public class OpenResearchFundAction extends Action {
	
	private FundDAO fundDAO;
	
	public OpenResearchFundAction(Model model) {
		fundDAO = model.getFundDAO();
	}                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              

	@Override
	public String getName() {
		// TODO Auto-generated method stub
		return "openResearchFund.do";
	}

	@Override
	public String perform(HttpServletRequest request) {
		try {
			List<Fund> allFunds = fundDAO.getAllFund();
		    request.setAttribute("allFunds", allFunds);
			
		    return "openResearchFund.jsp";
		} catch (Exception e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
			return "error.jsp";
		}

	}

	 @Override
		public UserType getType() {
		 return UserType.Both;
	 }
}